package com.example.mrzhou.lvmm.view.adapter.surround;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.mrzhou.lvmm.R;
import com.example.mrzhou.lvmm.commom.utils.ImageLoader;
import com.example.mrzhou.lvmm.entity.surround.hotel.Hotel;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Mr.zhou on 2016/10/27.
 */

public class HotelAdapter extends RecyclerView.Adapter<HotelAdapter.HotelViewHolder> {


    private List<Hotel.DataBean.HotelListBean> data;
    private Context context;

    public HotelAdapter(List<Hotel.DataBean.HotelListBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public HotelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new HotelViewHolder(LayoutInflater.from(context).inflate(R.layout.item_list_sur_hotel, parent, false));
    }

    @Override
    public void onBindViewHolder(HotelViewHolder holder, int position) {
        ImageLoader.getInstance().displayImage(data.get(position).getImages(), context, holder.ivHotelImg);
        holder.tvHotelName.setText(data.get(position).getName());
        holder.tvHotelType.setText(data.get(position).getPlaceType());
        holder.tvHotelJl.setText(data.get(position).getDistance());
        holder.tvHotelPrice.setText("¥"+data.get(position).getSellPrice()+"起");
    }

    @Override
    public int getItemCount() {
        return data != null ? data.size() : 0;
    }

    public class HotelViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_hotel_img)
        ImageView ivHotelImg;
        @BindView(R.id.tv_hotel_name)
        TextView tvHotelName;
        @BindView(R.id.tv_hotel_type)
        TextView tvHotelType;
        @BindView(R.id.tv_hotel_jl)
        TextView tvHotelJl;
        @BindView(R.id.tv_hotel_price)
        TextView tvHotelPrice;

        public HotelViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
